#!/bin/bash

# ----------------------------------------------------------------------
# Filename:   75585-c++.sh
# Version:    1.0
# Date:       2014/07/10
# Author:     jinzhao.wang
# Email:      jinzhao.wang@cs2c.com.cn
# Summary:    02系统基本功能-07开发环境-01语言支持-07C++语言
# Notes:      C++语言
# Copyright:  China Standard Software Co., Ltd.
# History：     
#             Version 1.0, 2013/12/02
#             -   The first one
#             Version 1.1, 2014/11/24
#             -   The second one;
#             -   Add SFROOT;

# ----------------------------------------------------------------------
if [ -z "$SFROOT" ]
then
    CMDLIB=./
    SFROOT=./
else
    CMDLIB=${SFROOT}/testcases/Development_Environment
fi

. ${SFROOT}/lib/Echo.sh
. ${SFROOT}/lib/XmlParse.sh



function CleanData ()
{
  rm -rf hello.cpp
  rm -rf hello
  EchoInfo "75585-c++.sh执行完毕"
}

trap "CleanData" EXIT INT

#执行C++文件
echo "#include <iostream>" >hello.cpp
echo "using namespace std;" >>hello.cpp
echo "int main()" >>hello.cpp
echo "{" >>hello.cpp
echo 'cout<<"hello world!"<<endl;' >>hello.cpp
echo "return 0;" >>hello.cpp
echo "}" >>hello.cpp
cat hello.cpp
g++ -o hello hello.cpp
[ -n "`file hello | grep executable`" ] 
EchoResult "C++文件编译成功"


[ "`./hello`" == "hello world!" ]
EchoResult "执行.cpp文件成功"

